package com.leanote.berial.tingphone.impl;

/**
 * Created with InetlliJ IDEA.
 * Project: com.liuhui.zhufengfm.app.tasks
 * user  Pinocchio
 * Date 2015/7/28
 * Email:liu594545591@126.com
 */

import com.leanote.berial.tingphone.TaskConstants;
import com.leanote.berial.tingphone.client.ClientDiscoverAPI;
import com.leanote.berial.tingphone.tasks.BaseTask;
import com.leanote.berial.tingphone.tasks.TaskCallback;
import com.leanote.berial.tingphone.tasks.TaskResult;
import org.json.JSONException;
import org.json.JSONObject;

/**
 *category_tag_menu<br/></>
 * 这个任务支持一个参数,参数是内容,是type的值
 * 只可以写user
 */
public class CategoryTagMenuTask extends BaseTask {
    public CategoryTagMenuTask(TaskCallback callback) {
        super(callback);
    }

    @Override
    protected TaskResult doInBackground(String... params) {
        //TaskResult必须创建,用来描述任务类型以及数据
        TaskResult ret = new TaskResult();
        ret.taskId = TaskConstants.TASK_CATEGORY_TAG_MENU;
        //////////////
        String type = null;
        if (params!=null&&params.length>0){
            type = params[0];
        }
        String str = ClientDiscoverAPI.getCategoryTagMenu(type);
        if (str != null) {
            try {
                ret.data = new JSONObject(str);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        return ret;
    }
}
